/*
 * $Id: ces.h,v 1.12.2.13 Broadcom SDK $
 * 
 * $Copyright: Copyright 2011 Broadcom Corporation.
 * This program is the proprietary software of Broadcom Corporation
 * and/or its licensors, and may only be used, duplicated, modified
 * or distributed pursuant to the terms and conditions of a separate,
 * written license agreement executed between you and Broadcom
 * (an "Authorized License").  Except as set forth in an Authorized
 * License, Broadcom grants no license (express or implied), right
 * to use, or waiver of any kind with respect to the Software, and
 * Broadcom expressly reserves all rights in and to the Software
 * and all intellectual property rights therein.  IF YOU HAVE
 * NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS SOFTWARE
 * IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
 * ALL USE OF THE SOFTWARE.  
 *  
 * Except as expressly set forth in the Authorized License,
 *  
 * 1.     This program, including its structure, sequence and organization,
 * constitutes the valuable trade secrets of Broadcom, and you shall use
 * all reasonable efforts to protect the confidentiality thereof,
 * and to use this information only in connection with your use of
 * Broadcom integrated circuit products.
 *  
 * 2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS
 * PROVIDED "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
 * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
 * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE.  BROADCOM SPECIFICALLY
 * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
 * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
 * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
 * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING
 * OUT OF USE OR PERFORMANCE OF THE SOFTWARE.
 * 
 * 3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL
 * BROADCOM OR ITS LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL,
 * INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY DAMAGES WHATSOEVER
 * ARISING OUT OF OR IN ANY WAY RELATING TO YOUR USE OF OR INABILITY
 * TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF
 * THE AMOUNT ACTUALLY PAID FOR THE SOFTWARE ITSELF OR USD 1.00,
 * WHICHEVER IS GREATER. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING
 * ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.$
 * 
 * DO NOT EDIT THIS FILE!
 * This file is auto-generated.
 * Edits to this file will be lost when it is regenerated.
 */

#ifndef __BCM_CES_H__
#define __BCM_CES_H__

#include <bcm/types.h>

#if defined(INCLUDE_CES)
#define BCM_CES_WITH_ID             (1 << 0)   /* Use the specified CES Service
                                                  ID */
#define BCM_CES_TDM_UPDATE_WITH_ID  (1 << 1)   /* TDM port associated with the
                                                  specified CES service has
                                                  changed */
#endif

#if defined(INCLUDE_CES)
#define BCM_CES_TDM_MAX                 16         /* Maximum number of TDM
                                                      ports supported */
#define BCM_CES_SLOT_MAX                32         /* Maximum number of TDM time
                                                      slots supported */
#define BCM_CES_CIRCUIT_IDX_MAX         64         /* Maximum number of CES
                                                      services supported */
#define BCM_CES_PROTO_VLAN_TAG_MAX      2          /* Maximum number of VLAN
                                                      tags supported */
#define BCM_CES_PROTO_MPLS_LABEL_MAX    1          /* Maximum number of MPLS
                                                      labels supported */
#define BCM_CES_RPC_CCNT_MAX            4          /* Maximum number of RPC per
                                                      service pm counts
                                                      supported */
#define BCM_CES_RPC_CGLB_MAX            8          /* Maximum number of RPC
                                                      global pm counts supported */
#define BCM_CES_CW_L                    0x800      /* Bit mask for CW L bit */
#define BCM_CES_CW_R                    0x400      /* Bit mask for CW R bit */
#define BCM_CES_CW_M                    0x300      /* Bit mask for CW M bit */
#define BCM_CES_CW_L_START_BIT          0xb        /* Bit number for CW L bit */
#define BCM_CES_CW_R_START_BIT          0xa        /* Bit number for CW R bit */
#define BCM_CES_CW_M_START_BIT          0x8        /* Bit number for CW M bit */
#define BCM_CES_LOPS_THRESHOLD_TABLE    1          /* Number of entries in the
                                                      LOPS threshold table */
#define BCM_CES_AOPS_THRESHOLD_TABLE    1          /* Number of entries in the
                                                      AOPS threshold table */
#define BCM_CES_FILLER_BYTE             0xD7       /* Default filler byte */
#define BCM_CES_IDLE_BYTE               0x7F       /* Default idle byte */
#define BCM_CES_LAN_DCE_MODE_ENABLE     0          /* LAN DCE mode enable */
#define BCM_CES_WAN_DCE_MODE_ENABLE     0          /* WAN DCE mode enable */
#define BCM_CES_CAS_E1_IDLE_PATTERN     0xff       /* Signaling idle pattern for
                                                      E1. */
#define BCM_CES_CAS_T1_IDLE_PATTERN     0xff       /* Signaling idle pattern for
                                                      T1. */
#define BCM_CES_CAS_NO_CHANGE_DELAY     5          /* Time in seconds between
                                                      OOB CAS packets when no
                                                      signaling changes */
#define BCM_CES_CAS_CHANGE_DELAY        5          /* Time in milliseconds
                                                      between OOB CAS packets
                                                      when signaling changes */
#define BCM_CES_CAS_SQN_WINDOW          50         /* JBF window for CAS packet
                                                      sequence number validation */
#define BCM_CES_PAUSE_QUANTA            0          /* Pause quanta used in each
                                                      pause frame. */
#define BCM_CES_RX_SECTION_EMPTY        0          /* Receive FIFO section empty
                                                      threshold. */
#define BCM_CES_RX_SECTION_FULL         16         /* Receive FIFO section full
                                                      threshold. */
#define BCM_CES_TX_SECTION_EMPTY        0          /* Transmit FIFO section
                                                      empty threshold. */
#define BCM_CES_TX_SECTION_FULL         16         /* Transmit FIFO section full
                                                      threshold. */
#define BCM_CES_RX_ALMOST_EMPTY         8          /* Receive FIFO FIFO almost
                                                      empty threshold. */
#define BCM_CES_RX_ALMOST_FULL          10         /* Receive FIFO FIFO almost
                                                      full threshold. */
#define BCM_CES_TX_ALMOST_EMPTY         8          /* Transmit FIFO almost empty
                                                      threshold. */
#define BCM_CES_TX_ALMOST_FULL          11         /* Transmit FIFO almost full
                                                      threshold. */
#define BCM_CES_T1_PAYLOAD_SIZE         192        /* Payload size for full T1
                                                      (24 * 8). */
#define BCM_CES_E1_PAYLOAD_SIZE         256        /* Payload size for full E1
                                                      (32 * 8). */
#define BCM_CES_PACKET_BUFFER_SIZE      2048       /* Packet buffer size. */
#define BCM_CES_JBF_RING_SIZE           32         /* Jitter buffer ring size. */
#define BCM_CES_JBF_WINDOW_SIZE         16         /* Jitter buffer window size. */
#define BCM_CES_JBF_BREAK_OUT_POINT     10         /* Jitter buffer break out
                                                      point. */
#endif

#if defined(INCLUDE_CES)
/* Encapsulation type */
typedef enum bcm_ces_encapsulation_e {
    bcmCesEncapsulationIp = 0,  /* IP */
    bcmCesEncapsulationMpls,    /* MPLS */
    bcmCesEncapsulationEth,     /* ETH */
    bcmCesEncapsulationL2tp = 5 /* L2TP */
} bcm_ces_encapsulation_t;
#endif

#if defined(INCLUDE_CES)
/* TDM port receive clock source */
typedef enum bcm_ces_rx_clk_select_e {
    bcmCesRxClkSelectIndependent = 0,   /* Independent of CES clock */
    bcmCesRxClkSelectCesSlave           /* Use CES clock */
} bcm_ces_rx_clk_select_t;
#endif

#if defined(INCLUDE_CES)
/* TDM port transmit clock source */
typedef enum bcm_ces_tx_clk_select_e {
    bcmCesTxClkSelectLoopback = 0,      /* Loopback RCLK */
    bcmCesTxClkSelectCclk = 2,          /* Common clock */
    bcmCesTxClkSelectInternalBrg = 3    /* Internal BRG */
} bcm_ces_tx_clk_select_t;
#endif

#if defined(INCLUDE_CES)
/* Common clock source */
typedef enum bcm_ces_cclk_select_e {
    bcmCesCclkSelectRefClk1 = 0,    /* Reference 1 */
    bcmCesCclkSelectRefClk2,        /* Reference 2 */
    bcmCesCclkSelectExternalClk     /* External clock */
} bcm_ces_cclk_select_t;
#endif

#if defined(INCLUDE_CES)
/* Reference clock source select */
typedef enum bcm_ces_ref_clk_select_e {
    bcmCesRefClkSelectRclk = 0,     /* RCLK */
    bcmCesRefClkSelectRefInput1,    /* Clock reference 1 */
    bcmCesRefClkSelectRefInput2,    /* Clock reference 2 */
    bcmCesRefClkSelectNomadBrg,     /* NOMAD bit rate generator */
    bcmCesRefClkSelectPortBrg,      /* Port bit rate generator */
    bcmCesRefClkSelectPtp = 7       /* PTP */
} bcm_ces_ref_clk_select_t;
#endif

#if defined(INCLUDE_CES)
/* External clock direction */
typedef enum bcm_ces_ext_clk_dir_e {
    bcmCesExtClkDirInput = 0,   /* External clock direction input */
    bcmCesExtClkDirOutput       /* External clock direction output */
} bcm_ces_ext_clk_dir_t;
#endif

#if defined(INCLUDE_CES)
/* TDM protocol */
typedef enum bcm_ces_tdm_proto_e {
    bcmCesTdmProtocolE1 = 0,    /* E1 protocol */
    bcmCesTdmProtocolT1         /* T1 protocol */
} bcm_ces_tdm_proto_t;
#endif

#if defined(INCLUDE_CES)
/* Sync type */
typedef enum bcm_ces_sync_type_e {
    bcmCesPacketSyncLops = 0,   /* LOPS Sync */
    bcmCesPacketSyncAops        /* AOPS Sync */
} bcm_ces_sync_type_t;
#endif

#if defined(INCLUDE_CES)
/* Jitter buffer state */
typedef enum bcm_ces_jbf_state_e {
    bcmCesJitterBufferStateIdle = 0, 
    bcmCesJitterBufferStateFill, 
    bcmCesJitterBufferStateNormal, 
    bcmCesJitterBufferStateFlush 
} bcm_ces_jbf_state_t;
#endif

#if defined(INCLUDE_CES)
typedef enum bcm_ces_pr_e {
    bcmCesPrpNoChange = 0, 
    bcmCesPrpFirst = bcmCesPrpNoChange, 
    bcmCesPrpIdleByte, 
    bcmCesPrpFillerByte, 
    bcmCesPrpAllOnes, 
    bcmCesPrpLast = bcmCesPrpAllOnes 
} bcm_ces_pr_t;
#endif

#if defined(INCLUDE_CES)
typedef enum bcm_ces_rai_detect_e {
    bcmCesRaiDetectM = 2, 
    bcmCesRaiDetectR = 1 
} bcm_ces_rai_detect_t;
#endif

#if defined(INCLUDE_CES)
/* CES Loopback types */
typedef enum bcm_ces_loopback_e {
    bcmCesLoopbackNone, 
    bcmCesLoopbackTdmRemote, 
    bcmCesLoopbackTdmLocal, 
    bcmCesLoopbackChannelizer, 
    bcmCesLoopbackDechannelizer, 
    bcmCesLoopbackClassifier, 
    bcmCesLoopbackPacketInterface, 
    bcmCesLoopbackPacketLocal, 
    bcmCesLoopbackPacketRemote 
} bcm_ces_loopback_t;
#endif

#if defined(INCLUDE_CES)
/* TDM Port CAS status selection */
typedef enum bcm_tdm_port_cas_status_e {
    bcmTdmPortCasStatusEgress, 
    bcmTdmPortCasStatusIngress 
} bcm_tdm_port_cas_status_t;
#endif

#if defined(INCLUDE_CES)
/* CES CAS status selection */
typedef enum bcm_ces_cas_status_e {
    bcmCesCasStatusEgress, 
    bcmCesCasStatusIngress 
} bcm_ces_cas_status_t;
#endif

#if defined(INCLUDE_CES)
/* IP Protocol version */
typedef enum bcm_ces_ip_version_e {
    bcmCesIpV4 = 4, 
    bcmCesIpV6 = 6 
} bcm_ces_ip_version_t;
#endif

#if defined(INCLUDE_CES)
/* Ethernet protocol data */
typedef struct bcm_ces_proto_eth_s {
    uint8 source[6];        /* Source MAC */
    uint8 destination[6];   /* Destination MAC */
} bcm_ces_proto_eth_t;
#endif

#if defined(INCLUDE_CES)
typedef struct bcm_ces_proto_vlan_s {
    uint32 priority;    /* VLAN priority */
    uint32 vid;         /* VLAN tag */
} bcm_ces_proto_vlan_t;
#endif

#if defined(INCLUDE_CES)
typedef struct bcm_ces_proto_ipv4_s {
    uint32 tos;         /* IPv4 TOS */
    uint32 ttl;         /* IPv4 TTL */
    uint32 source;      /* IPv4 source address */
    uint32 destination; /* IPv4 destination address */
} bcm_ces_proto_ipv4_t;
#endif

#if defined(INCLUDE_CES)
typedef struct bcm_ces_proto_ipv6_s {
    uint32 traffic_class;   /* IPv6 traffic class */
    uint32 flow_label;      /* IPv6 flow label */
    uint32 hop_limit;       /* IPv6 hop limit */
    uint32 source[16];      /* IPv6 source address */
    uint32 destination[16]; /* IPv6 destination address */
} bcm_ces_proto_ipv6_t;
#endif

#if defined(INCLUDE_CES)
typedef struct bcm_ces_proto_mpls_s {
    uint32 label;           /* MPLS label table */
    uint32 experimental;    /* MPLS experimental value table */
    uint32 ttl;             /* MPLS TTL table */
} bcm_ces_proto_mpls_t;
#endif

#if defined(INCLUDE_CES)
typedef struct bcm_ces_proto_udp_s {
    uint32 destination; /* UDP destination port */
    uint32 source;      /* UDP source port */
} bcm_ces_proto_udp_t;
#endif

#if defined(INCLUDE_CES)
typedef struct bcm_ces_proto_l2tpv3_s {
    int udp_mode;               /* UDP mode */
    uint32 header;              /* Header */
    uint32 session_local_id;    /* Session local ID */
    uint32 session_peer_id;     /* Session peer ID */
    uint32 local_cookie1;       /* Local cookie 1 */
    uint32 local_cookie2;       /* Local cookie 2 */
    uint32 peer_cookie1;        /* Peer cookie 1 */
    uint32 peer_cookie2;        /* Peer cookie 2 */
} bcm_ces_proto_l2tpv3_t;
#endif

#if defined(INCLUDE_CES)
/* Packet header descriptor */
typedef struct bcm_ces_packet_header_s {
    bcm_ces_encapsulation_t encapsulation; /* Encapsulation type */
    bcm_ces_proto_eth_t eth;            /* Ethernet protocol parameters */
    bcm_ces_proto_vlan_t vlan[BCM_CES_PROTO_VLAN_TAG_MAX]; /* VLAN table */
    bcm_ces_proto_ipv4_t ipv4;          /* IPv4 protocol parameters */
    bcm_ces_proto_ipv6_t ipv6;          /* IPv6 protocol parameters */
    bcm_ces_proto_mpls_t mpls[BCM_CES_PROTO_MPLS_LABEL_MAX]; /* MPLS table */
    bcm_ces_proto_l2tpv3_t l2tpv3;      /* L2TPV3 protocol parameters */
    uint32 vc_label;                    /* Virtual circuit label */
    bcm_ces_proto_udp_t udp;            /* UDP protocol parameters */
    uint32 rtp_pt;                      /* Real Time Protocol port */
    uint32 rtp_ssrc;                    /* Real Time Protocol SSRC */
    uint32 ip_version;                  /* IP Version used in header */
    uint32 vlan_count;                  /* Number of VLANs */
    uint32 mpls_count;                  /* Number of MPLS labels */
    uint32 l2tpv3_count;                /* L2TPv3 count */
    int rtp_exists;                     /* Is RTP supported */
    int udp_chksum;                     /* Use UDP checksums */
} bcm_ces_packet_header_t;
#endif

#if defined(INCLUDE_CES)
/* bcm_ces_service_t */
typedef int bcm_ces_service_t;
#endif

#if defined(INCLUDE_CES)
/* TDM Circuit configuration */
typedef struct bcm_ces_circuit_config_s {
    bcm_ces_tdm_proto_t tdm_protocol;   /* TDM protocol selection, T1 or E1 */
    int structured;                     /* Boolean, is TDM circuit structured? 0
                                           = unstructured, 1 = structured */
    int octet_aligned;                  /* Boolean, is TDM circuit octet
                                           aligned?, 0 = unaligned, 1 = aligned.
                                           Aligned only valid for T1
                                           unstructured */
    int signaling_enable;               /* Boolean, is CAS signalling to be
                                           used?, 0 = no, 1 = yes */
    int t1_d4_framing;                  /* Boolean, 0 = no, 1 = yes. Applies
                                           only to T1 with CAS signaling */
    uint32 clk_rx_select;               /* Selects receive clock source */
    uint32 clk_tx_select;               /* Selects transmit clock source */
} bcm_ces_circuit_config_t;
#endif

#if defined(INCLUDE_CES)
/* Ingress channel config */
typedef struct bcm_ces_ingress_channel_config_s {
    uint32 payload_size;    /* Transmit packet payload size in bytes */
    int dba;                /* Boolean, enables payload compression mode when
                               transmitting packets wit the L bit set */
    int auto_r_bit;         /* Boolean. Enables automatic R bit insertion in the
                               CES control word of transmitted packets upon
                               detection of LOPS in the corresponding (the same
                               channel id) egress channel. This feature can be
                               used only in case of symmetrical channel id
                               allocation, i.e. egress channel id is equal to
                               ingress channel id */
    int mef_len_support;    /* Boolean. 1 = support, the length field value for
                               ingress TDM traffic will be computed according to
                               MEF standard. 0 = not supported, the length field
                               will be always set to 0 */
    uint32 pbf_size;        /* Payload buffer size in bytes for this channel.
                               The values allowed are 64, 128, 256, 512, 1024,
                               2048, 4096 and 8192. The value configured should
                               not exceed the n_pbf_max parameter value of
                               ag_nd_device_open. */
} bcm_ces_ingress_channel_config_t;
#endif

#if defined(INCLUDE_CES)
/* Egress channel configuration */
typedef struct bcm_ces_egress_channel_config_s {
    uint32 packet_sync_selector;    /* Selects a pair of packet sync
                                       loss/acquisition thresholds. Valid range
                                       is from 0 to BCM_CES_THRESHOLD_TABLE_SIZE
                                       - 1 */
    int rtp_exists;                 /* Configures the existence of RTP header.
                                       Set to 1 if the RTP header is in use, or
                                       0 otherwise. */
    uint32 payload_size;            /* Receive packet payload size (bytes) */
    uint32 jbf_ring_size;           /* Jitter buffer ring size (in packets). The
                                       values allowed are: 8, 16, 32, 64, 128,
                                       256, 512 and 1024. The value can not
                                       exceed the maximum value determined from
                                       number of PWs supported and VBA size
                                       configured by ag_nd_device_open. */
    uint32 jbf_win_size;            /* Jitter buffer window size limit
                                       (packets). The values allowed are 8, 16,
                                       32, 64, 128, 256, 512. Additional option
                                       is BCM_CES_JBF_NO_LIMIT. This setting
                                       disables the packet drop criteria based
                                       on sequence number, i.e. any incoming
                                       packet will be accepted. */
    uint32 jbf_bop;                 /* Jitter buffer break out point (packets).
                                       The sum of n_jbf_win_size and n_jbf_bop
                                       should not exceed the n_jbf_ring_size
                                       parameter value. Or in the case
                                       n_jbf_win_size is set to
                                       BCM_CES_JBF_NO_LIMIT, the value of
                                       n_jbf_bop should not exceed
                                       n_jbf_ring_size. */
} bcm_ces_egress_channel_config_t;
#endif

#if defined(INCLUDE_CES)
/* Channel mappings */
typedef struct bcm_ces_channel_map_s {
    uint16 circuit_id[BCM_CES_SLOT_MAX * BCM_CES_CIRCUIT_IDX_MAX]; /* Together with slot[] contains the
                                           list of timeslots that belong to
                                           channel. */
    uint16 slot[BCM_CES_SLOT_MAX * BCM_CES_CIRCUIT_IDX_MAX]; 
    uint32 size;                        /* Specifies the number of valid entries
                                           in the circuit_id and slot tables. */
    uint32 first;                       /* Specifies the first valid entry in
                                           the circuit_id and slot tables. */
} bcm_ces_channel_map_t;
#endif

#if defined(INCLUDE_CES)
/* CES service configuration */
typedef struct bcm_ces_service_config_s {
    uint32 flags;                       /* Misc control flags */
    bcm_ces_channel_map_t ingress_channel_map; /* Ingress TDM port and timeslots */
    bcm_ces_channel_map_t egress_channel_map; /* Egress TDM port and timeslots */
    bcm_ces_ingress_channel_config_t ingress_channel_config; /* Ingress channel configuration */
    bcm_ces_packet_header_t header;     /* Packet header */
    bcm_ces_egress_channel_config_t egress_channel_config; /* Egress channel configuration */
    bcm_ces_packet_header_t strict_data; /* Received packet header match criteria */
    bcm_mac_t dest_mac;                 /* Destination MAC address */
    bcm_ces_encapsulation_t encapsulation; /* CES encapsulation type */
} bcm_ces_service_config_t;
#endif

#if defined(INCLUDE_CES)
typedef struct bcm_ces_service_pm_stats_s {
    uint32 jbf_depth_min;               /* Jitter buffer minimum depth */
    uint32 jbf_depth_max;               /* Jitter buffer maximum depth */
    uint32 jbf_underruns;               /* Jitter buffer underruns */
    uint32 jbf_missing_packets;         /* Jitter buffer missing packets */
    uint32 jbf_dropped_ooo_packets;     /* Jitter buffer dropped out of order
                                           packets. */
    uint32 jbf_reordered_ooo_packets;   /* Jitter buffer reordered out of order
                                           packets. */
    uint32 jbf_bad_length_packets;      /* Jitter bad length packets. */
    uint32 received_bytes;              /* Received packet classifier in bytes. */
    uint32 received_packets;            /* Received packet classifier in packets */
    uint32 rpc_channel_specific[BCM_CES_RPC_CCNT_MAX]; /* Received packet classifier channel
                                           specific. */
    uint32 cas_dropped;                 /* CAS dropped */
    uint32 pbf_utilization;             /* Buffer utilization */
    uint32 transmitted_bytes;           /* Output byte count */
    uint32 transmitted_packets;         /* Output packet count */
    uint32 cas_tx;                      /* CAS tx count */
} bcm_ces_service_pm_stats_t;
#endif

#if defined(INCLUDE_CES)
/* Flags for use with bcm_ces_cas_packet_control_t */
typedef enum bcm_ces_cas_packet_control_flags_e {
    bcmCesCasPacketSchedule = 0 /* Enable scheduling of n CAS packets */
} bcm_ces_cas_packet_control_flags_t;
#endif

#if defined(INCLUDE_CES)
typedef struct bcm_ces_cas_packet_control_s {
    int flags;              /* Control flags */
    uint32 packet_count;    /* Number of packets to enable */
} bcm_ces_cas_packet_control_t;
#endif

#if defined(INCLUDE_CES)
typedef struct bcm_ces_service_egress_status_s {
    bcm_ces_sync_type_t sync_state; /* Sync state */
    bcm_ces_jbf_state_t jbf_state;  /* Jitter buffer state */
    uint32 ces_cw;                  /* CES cw */
    int trimming;                   /* Trimming state */
} bcm_ces_service_egress_status_t;
#endif

#if defined(INCLUDE_CES)
/* Common clock configuration */
typedef struct bcm_ces_cclk_config_s {
    int cclk_enable;                    /* Boolean. Should be set to 1 in order
                                           to drive framer RSYSCLK */
    bcm_ces_cclk_select_t cclk_select;  /* Common clock source select. */
    bcm_ces_tdm_proto_t ref_clk_proto;  /* Selects reference clock protocol. */
    bcm_ces_ref_clk_select_t ref_clk_1_select; /* Reference clock 1 source select */
    bcm_ces_ref_clk_select_t ref_clk_2_select; /* Reference clock 2 source select */
    uint32 ref_clk_1_port;              /* Selects reference clock 1 RCLK source
                                           port number */
    uint32 ref_clk_2_port;              /* Selects reference clock 2 RCLK source
                                           port number */
    uint32 ref_clk_1_brg;               /* Selects reference clock 1 RCLK BRG
                                           port number */
    uint32 ref_clk_2_brg;               /* Selects reference clock 2 RCLK BRG
                                           port number */
    uint32 ext_clk_1_dir;               /* External-clock 1 direction */
    uint32 ext_clk_2_dir;               /* External-clock 2 direction */
} bcm_ces_cclk_config_t;
#endif

#if defined(INCLUDE_CES)
/* Received clock configuration */
typedef struct bcm_ces_rclock_config_s {
    int enable;             /* Enable received clock instance */
    uint8 output_brg;       /* 0 = port'd brg, 1 = system brg1, 2 = system brg2 */
    uint8 rclock;           /* Received clock instance, 0 through 3 */
    uint8 port;             /* If output_brg is set to port brg then this is por
                               that will be used */
    uint8 recovery_type;    /* 0 = adaptive, 1 = differential */
} bcm_ces_rclock_config_t;
#endif

#if defined(INCLUDE_CES)
/* MAC configuration */
typedef struct bcm_ces_mac_cmd_config_s {
    int b_rx_error_discard_enable;      /* Discard errored frames */
    int b_no_length_check;              /* Don't check packet length */
    int b_control_frame_enable;         /* Enable control frames */
    int b_node_wake_up_request_indication; /* WAKEUP request indication */
    int b_put_core_in_sleep_mode;       /* Put core in sleep mode */
    int b_enable_magic_packet_detection; /* Enable magic packet detection */
    int b_software_reset;               /* Reset MAC core */
    int b_is_late_collision_condition;  /* Was late collision detected by the
                                           core */
    int b_is_excessive_collision_condition; /* Was excessive collision detected by
                                           the core */
    int b_enable_half_duplex;           /* Enable half-duplex work mode */
    int b_insert_mac_addr_on_transmit;  /* Insert MAC address on transmit */
    int b_ignore_pause_frame_quanta;    /* Ignore pause frame quanta */
    int b_fwd_pause_frames;             /* Forward/Discard pause frames */
    int b_fwd_crc_field;                /* Forward/Discard CRC fields */
    int b_enable_frame_padding;         /* Enable frame padding */
    int b_enable_promiscuous_mode;      /* Enable promiscuous mode */
    int b_enable_mac_receive;           /* Enable MAC receive path */
    int b_enable_mac_transmit;          /* Enable MAC transmit path */
} bcm_ces_mac_cmd_config_t;
#endif

#ifndef BCM_HIDE_DISPATCHABLE

#if defined(INCLUDE_CES)
/* Initialize CES module. */
extern int bcm_ces_init(
    int unit);
#endif

#if defined(INCLUDE_CES)
/* 
 * Initialize CES services subsystem. Deletes all current CES channels
 * and resets CES to the default configuration.
 */
extern int bcm_ces_services_init(
    int unit);
#endif

#if defined(INCLUDE_CES)
/* 
 * Initialize CES services subsystem without affecting current hardware
 * state.
 */
extern int bcm_ces_services_clear(
    int unit);
#endif

#if defined(INCLUDE_CES)
/* 
 * Allocate and configure a CES service. With the flags field set to 0
 * and no ces_service specified the configuration is applied entirely
 * from the config parameter. With the flags field set to BCM_CES_WITH_ID
 * the configuration is applied only for the substrutures that have
 * changed in the config parameter. With the BCM_CES_TDM_UPDATE_WITH_ID
 * flag set only configuration of the associated TDM port is applied, the
 * config field is ignored and may be set to NULL.
 */
extern int bcm_ces_service_create(
    int unit, 
    int flags, 
    bcm_ces_service_config_t *config, 
    bcm_ces_service_t *ces_service);
#endif

#if defined(INCLUDE_CES)
/* 
 * Deallocate a CES service. Frees all resources associated with the CES
 * service.
 */
extern int bcm_ces_service_destroy(
    int unit, 
    bcm_ces_service_t ces_service);
#endif

#if defined(INCLUDE_CES)
/* Deallocate all CES services. */
extern int bcm_ces_service_destroy_all(
    int unit);
#endif

#if defined(INCLUDE_CES)
/* Enables or disables a CES service. */
extern int bcm_ces_service_enable_set(
    int unit, 
    bcm_ces_service_t ces_service, 
    int enable);
#endif

#if defined(INCLUDE_CES)
/* Get CES service enable state. */
extern int bcm_ces_service_enable_get(
    int unit, 
    bcm_ces_service_t ces_service, 
    int *enable);
#endif

#if defined(INCLUDE_CES)
/* Get the current configuration parameters for a CES service. */
extern int bcm_ces_service_config_get(
    int unit, 
    bcm_ces_service_t ces_service, 
    bcm_ces_service_config_t *config);
#endif

#endif /* BCM_HIDE_DISPATCHABLE */

#if defined(INCLUDE_CES)
typedef int (*bcm_ces_service_traverse_cb)(
    int unit, 
    void *user_data);
#endif

#ifndef BCM_HIDE_DISPATCHABLE

#if defined(INCLUDE_CES)
/* List all currently configured CES services. */
extern int bcm_ces_services_traverse(
    int unit, 
    uint32 flags, 
    bcm_ces_service_traverse_cb cb, 
    void *user_data);
#endif

#if defined(INCLUDE_CES)
/* Enable or disable CAS signalling for a CES service. */
extern int bcm_ces_service_ingress_cas_enable_set(
    int unit, 
    bcm_ces_service_t ces_service, 
    int enable);
#endif

#if defined(INCLUDE_CES)
/* Get the CAS signalling enable status for a CES service. */
extern int bcm_ces_service_ingress_cas_enable_get(
    int unit, 
    bcm_ces_service_t ces_service, 
    int *enable);
#endif

#if defined(INCLUDE_CES)
/* Number of CAS packets to schedule for transmission on a CES service. */
extern int bcm_ces_service_cas_packet_enable(
    int unit, 
    bcm_ces_service_t ces_service, 
    bcm_ces_cas_packet_control_t *cas_packet);
#endif

#if defined(INCLUDE_CES)
/* Gets the CES seervice egress status. */
extern int bcm_ces_egress_status_get(
    int unit, 
    bcm_ces_service_t ces_service, 
    bcm_ces_service_egress_status_t *status);
#endif

#if defined(INCLUDE_CES)
/* Gets the performace monitoring stats for a CES service. */
extern int bcm_ces_service_pm_get(
    int unit, 
    bcm_ces_service_t ces_service, 
    bcm_ces_service_pm_stats_t *stats);
#endif

#if defined(INCLUDE_CES)
/* Resets the performace monitoring stats for a CES seervice. */
extern int bcm_ces_service_pm_clear(
    int unit, 
    bcm_ces_service_t ces_service);
#endif

#if defined(INCLUDE_CES)
/* 
 * Set the clock configuration parameters that are common to all CES
 * services.
 */
extern int bcm_ces_services_cclk_config_set(
    int unit, 
    bcm_ces_cclk_config_t *config);
#endif

#if defined(INCLUDE_CES)
/* 
 * Get the clock configuration parameters that are common to all CES
 * services.
 */
extern int bcm_ces_services_cclk_config_get(
    int unit, 
    bcm_ces_cclk_config_t *config);
#endif

#if defined(INCLUDE_CES)
/* 
 * Set the received clock timing configuration parameters for a CES
 * service.
 */
extern int bcm_ces_service_rclock_config_set(
    int unit, 
    bcm_ces_service_t ces_service, 
    bcm_ces_rclock_config_t *config);
#endif

#if defined(INCLUDE_CES)
/* 
 * Get the received clock timing configuration parameters for a CES
 * service.
 */
extern int bcm_ces_service_rclock_config_get(
    int unit, 
    bcm_ces_service_t ces_service, 
    bcm_ces_rclock_config_t *config);
#endif

#if defined(INCLUDE_CES)
/* Attach the CES MII port to the specified ingress pipeline port */
extern int bcm_ces_attach_ethernet(
    int unit, 
    int port);
#endif

#if defined(INCLUDE_CES)
/* Apply CES specific MAC configuration */
extern int bcm_ces_ethernet_config_set(
    int unit, 
    int port, 
    bcm_ces_mac_cmd_config_t *config);
#endif

#if defined(INCLUDE_CES)
/* Recover CES specific MAC configuration */
extern int bcm_ces_ethernet_config_get(
    int unit, 
    int port, 
    bcm_ces_mac_cmd_config_t *config);
#endif

#endif /* BCM_HIDE_DISPATCHABLE */

#if defined(INCLUDE_CES)
/* bcm_ces_service_config_t_init */
extern void bcm_ces_service_config_t_init(
    bcm_ces_service_config_t *config);
#endif

#if defined(INCLUDE_CES)
/* bcm_ces_cclk_config_t_init */
extern void bcm_ces_cclk_config_t_init(
    bcm_ces_cclk_config_t *config);
#endif

#if defined(INCLUDE_CES)
/* bcm_ces_rclock_config_t_init */
extern void bcm_ces_rclock_config_t_init(
    bcm_ces_rclock_config_t *config);
#endif

#endif /* __BCM_CES_H__ */
